// Decompiled on 周六 2月 22 19:31:49 CST 2025 with Zomboid Decompiler v0.1.3 using Vineflower.
package zombie.commands.serverCommands;

import zombie.characters.IsoPlayer;
import zombie.commands.CommandArgs;
import zombie.commands.CommandBase;
import zombie.commands.CommandName;
import zombie.commands.RequiredRight;
import zombie.core.raknet.UdpConnection;
import zombie.network.GameServer;

@CommandName(
    name = "debugplayer"
)
@CommandArgs(
    required = {"(.+)"}
)
@RequiredRight(
    requiredRights = 32
)
public class DebugPlayerCommand extends CommandBase {
    public DebugPlayerCommand(String username, String userAccessLevel, String command, UdpConnection connection) {
        super(username, userAccessLevel, command, connection);
    }

    @Override
    protected String Command() {
        if (this.getCommandArgsCount() != 1) {
            return "/debugplayer \"username\"";
        } else {
            String string = this.getCommandArg(Integer.valueOf(0));
            IsoPlayer isoPlayer = GameServer.getPlayerByUserNameForCommand(string);
            if (isoPlayer == null) {
                return "no such user";
            } else {
                UdpConnection udpConnection = GameServer.getConnectionByPlayerOnlineID(isoPlayer.OnlineID);
                if (udpConnection == null) {
                    return "no connection for user";
                } else if (GameServer.DebugPlayer.contains(udpConnection)) {
                    GameServer.DebugPlayer.remove(udpConnection);
                    return "debug off";
                } else {
                    GameServer.DebugPlayer.add(udpConnection);
                    return "debug on";
                }
            }
        }
    }
}
